f = open ("dayup.txt","r")
xu = []
stu= []


for xline in f:
    (role,yline) = xline.split(":",1)
    if role == "徐老师":
        xu.append(yline)
    if role == "同学":
        stu.append(yline)

xufile = open ('E:\\代码\\Python\\文件操作\\xu.txt','w')
stufile= open ('E:\\代码\\Python\\文件操作\\stu.txt','w')

xufile.writelines(xu)
stufile.writelines(stu)

xufile.close()
stufile.close()
